package com.youkeda.comment.service;

import com.youkeda.comment.model.Comment;
import com.youkeda.comment.model.Result;

import java.util.List;

/**
 * @InterfaceName CommentService
 * @Author 刘正星
 * @Date 2020/7/18 16:23
 **/
public interface CommentService {


    /**
     * 查询
     * @return
     */
    //@Select("SELECT id,ref_id as refId,user_id as userId,parent_id as parentId,content,gmt_created as gmtCreated,gmt_modified as gmtModified FROM comment")
    List<Comment> findAll();

    /**
     * 插入
     * @param comment
     * @return 行数
     */
    /*@Insert("INSERT INTO comment (ref_id,user_id,content,parent_id,gmt_created,gmt_modified) VALUES(#{refId},#{userId},#{content},#{parentId},now(),now())")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insert(CommentDO commentDO);*/

    int add(Comment comment);

    /**
     * 更新
     * @param comment
     * @return 行数
     */
    //@Update("UPDATE comment set user_id = #{userId},content = #{content},gmt_modified = now() where id =#{id}")
    int update(Comment comment);

    /**
     * 删除
     * @param id
     * @return 行数
     */
    //@Delete("DELETE from comment where id =#{id}")
    int delete(long id);

    /**
     * 查找
     * @param refId
     * @return List<CommentDO>
     */
    //@Select("SELECT id,ref_id as refId,user_id as userId,parent_id as parentId,content,gmt_created as gmtCreated,gmt_modified as gmtModified FROM comment where ref_id = #{refId}")
    List<Comment> findByRefId(String refId);

    /**
     * 批量插入
     * @param comments
     * @return
     */
    int batchAdd( List<Comment> comments);

    /**
     * 批量查询
     * @param ids
     * @return
     */
    List<Comment> findByUserIds(List<Long> ids);
    /**
     * 发布评论
     * @param refId
     * @param userId
     * @param parentId
     * @param content
     * @return
     */
    public Result<Comment> post(String refId, long userId, long parentId, String content);
    /**
     * 查询评论
     *
     * @param refId
     * @return
     */
    public Result<List<Comment>> query(String refId);



}